import request from '@/utils/request'
import { parseStrEmpty } from "@/utils/ruoyi";

// 查询正负清单列表
export function listUser(query) {
  return request({
    url: '/civilServants',
    method: 'get',
    params: query
  })
}

// // 查询用户详细
// export function getUser(userId) {
//   return request({
//     url: '/system/user/' + parseStrEmpty(userId),
//     method: 'get'
//   })
// }


// 获取正负清单详情列表
export function getzhenglist(query) {
  return request({
    url: '/civilServantsList',
    method: 'get',
    params: query
  })
}

// 新增正负清单
export function addUser(data) {
  return request({
    url: 'civilServantsList',
    method: 'post',
    data: data
  })
}

// 修改正负清单
export function updateUser(data) {
  return request({
    url: 'civilServantsList',
    method: 'put',
    data: data
  })
}

// 删除正负清单
export function delUser(postIds) {
  return request({
    url: 'civilServantsList/?id=' + postIds,
    method: 'delete'
  })
}

// 批量删除正负清单
export function delUsers(postIds) {
  return request({
    url: 'civilServantsList/' + postIds,
    method: 'delete'
  })
}

// 查询正负清单详情下拉列表
export function gettypelist(query) {
  return request({
    url: '/listType',
    method: 'get',
    params: query
  })
}


// 上传图片
export function uploadimg(data) {
  return request({
    url: 'common/upload',
    method: 'post',
    data: data
  })
}


// 新增机关公务员列表
export function addjiguan(data) {
  return request({
    url: 'civilServants',
    method: 'post',
    data: data
  })
}


// 修改机关公务员列表
export function updatejiguan(data) {
  return request({
    url: 'civilServants',
    method: 'put',
    data: data
  })
}

// 删除机关公务员列表
export function deljiguan(postIds) {
  return request({
    url: 'civilServants/?id=' + postIds,
    method: 'delete'
  })
}

// 获取个人简历
export function getpersonalinformation(query) {
  return request({
    url: '/civilServants/resume',
    method: 'get',
    params: query
  })
}

// 机关公务员人数统计
export function sumUser(query) {
  return request({
    url: '/statistics/sumUser',
    method: 'get',
    params: query
  })
}

// 学历分布统计
export function degree(query) {
  return request({
    url: '/statistics/degree',
    method: 'get',
    params: query
  })
}

// 任正（副）级人数统计
export function office(query) {
  return request({
    url: '/statistics/office',
    method: 'get',
    params: query
  })
}




// 用户密码重置
export function resetUserPwd(userId, password) {
  const data = {
    userId,
    password
  }
  return request({
    url: '/system/user/resetPwd',
    method: 'put',
    data: data
  })
}

// 用户状态修改
export function changeUserStatus(userId, status) {
  const data = {
    userId,
    status
  }
  return request({
    url: '/system/user/changeStatus',
    method: 'put',
    data: data
  })
}

// 查询用户个人信息
export function getUserProfile() {
  return request({
    url: '/system/user/profile',
    method: 'get'
  })
}

// 修改用户个人信息
export function updateUserProfile(data) {
  return request({
    url: '/system/user/profile',
    method: 'put',
    data: data
  })
}

// 用户密码重置
export function updateUserPwd(oldPassword, newPassword) {
  const data = {
    oldPassword,
    newPassword
  }
  return request({
    url: '/system/user/profile/updatePwd',
    method: 'put',
    params: data
  })
}

// 用户头像上传
export function uploadAvatar(data) {
  return request({
    url: '/system/user/profile/avatar',
    method: 'post',
    data: data
  })
}

// 查询授权角色
export function getAuthRole(userId) {
  return request({
    url: '/system/user/authRole/' + userId,
    method: 'get'
  })
}

// 保存授权角色
export function updateAuthRole(data) {
  return request({
    url: '/system/user/authRole',
    method: 'put',
    params: data
  })
}

// 查询部门下拉树结构
export function deptTreeSelect() {
  return request({
    url: '/system/user/deptTree',
    method: 'get'
  })
}
